package com.util;

import java.sql.*;

public class DBCUtil {
    private static ResultSet rs = null;
    private static PreparedStatement statement = null;
    private static Connection connection = null;
    private DBCUtil (){}

    public static Connection getConnection(){
        try{
            Class.forName("com.mysql.cj.jdbc.Driver");
            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/zuhaowan?useunicode=true& characterEncoding=utf8","root","root");
        }catch (Exception e) {
            e.printStackTrace();
        }
        return connection;
    }
    
    public static void close(ResultSet rs,Statement stat,Connection conn){
        try {
            if(rs != null) {
                rs.close();
            }
            if(stat != null) {
                stat.close();
            }
            if(conn != null) {
                conn.close();
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}
